<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
<!--body, html,#allmap {width: 100%;height: 100%;overflow: hidden;}-->

</style>
<script type="text/JavaScript" src="http://api.map.baidu.com/api?v=3.0&ak=pv1tQCTFXzWnHUGfTDLb2GpSwltgDcnK"></script>
<title>在线地图_Demo</title>
</head>
<body>
<div style="left:0;top:0;width:100%;height:100%;position:absolute;" id="allmap"></div>
</body>
</html>
<script type="text/javascript" >
 
// 百度地图API功能
var map = new BMap.Map("allmap",{mapType: BMAP_SATELLITE_MAP});
map.addControl(new BMap.OverviewMapControl());              //添加缩略地图控件
map.addControl(new BMap.NavigationControl({offset: new BMap.Size(10, 60)}));//添加左上角缩放控件
map.addControl(new BMap.ScaleControl({anchor: BMAP_ANCHOR_BOTTOM_LEFT,offset: new BMap.Size(10, 60)}));//添加左下角比例尺控件byZS191220
map.enableScrollWheelZoom();                               //启用滚轮放大缩小
map.enableKeyboard();                                   // 启用键盘操作。
map.enableContinuousZoom();                             // 启用连续缩放
//map.centerAndZoom('北京航空航天大学',17);  


var point = new BMap.Point(117.002866, 40.0658472);// 测试平谷区地图 200522
map.centerAndZoom(point,16);
                          // 初始化地图,设置中心点坐标和地图级别。200228修改为5级
//GPStoBD(point);


var dragFlag=false;

//var PlaneIcon = new BMap.Icon("images/plane.png", new BMap.Size(30,30),{anchor: new BMap.Size(15,30)});//这句表示图片相对于所加的点的位置
//var PlaneIcon = new BMap.Icon("images/Position.png", new BMap.Size(50,50),{anchor: new BMap.Size(15,30)});//byZS191216
//var Plane = new BMap.Marker(point,{icon:PlaneIcon});                                                   // 创建标注
var PlaneIcon = new BMap.Icon("images/Point.png", new BMap.Size(25,50));//byZS191216
var Plane = new BMap.Marker(point,{icon:PlaneIcon});                                                   // 创建标注
var PlaneIcon_blue = new BMap.Icon("images/Point_blue.png", new BMap.Size(25,50));//byZS191216
var Plane_blue = new BMap.Marker(point,{icon:PlaneIcon_blue});                                                   // 创建标注
var PlaneIcon_green = new BMap.Icon("images/Point_green.png", new BMap.Size(25,50));//byZS191230
var Plane_green = new BMap.Marker(point,{icon:PlaneIcon_green});  
var PlaneIcon_yellow = new BMap.Icon("images/Point_yellow.png", new BMap.Size(25,50));//byZS191230
var Plane_yellow = new BMap.Marker(point,{icon:PlaneIcon_yellow}); 
var PlaneIcon_brown = new BMap.Icon("images/Point_brown.png", new BMap.Size(25,50));//byZS191230
var Plane_brown = new BMap.Marker(point,{icon:PlaneIcon_brown});                                                  // 创建标注
var polyline22;


//showAddressAdjust(117.002866, 40.0658472);
/**********描点模块******************************************************************/
//红色
function showAddressAdjust(longjitude,latitude)
{
    //var resultPoint = GpsToBaiduPoint(new BMap.Point(longjitude,latitude));
    //showAddress(resultPoint.lng,resultPoint.lat);
	showAddress(longjitude,latitude);
}

function showAddress(longjitude,latitude)
{
   var gpsPoint = new BMap.Point(longjitude, latitude);

   if(!dragFlag)
   {
     //map.panTo(gpsPoint);
   }
    var marker_red = new BMap.Marker(gpsPoint,{icon:PlaneIcon});
    //marker.setPosition(gpsPoint);
	map.centerAndZoom(gpsPoint,16);
    map.addOverlay(marker_red);                              // 加载标注
    //marker.setAnimation(BMAP_ANIMATION_BOUNCE);        // 跳动的动画
}
//蓝色
function showAddressAdjust_blue(longjitude,latitude)
{//byZS191222
    //var resultPoint = GpsToBaiduPoint(new BMap.Point(longjitude,latitude));
    //showAddress_blue(resultPoint.lng,resultPoint.lat);
	showAddress_blue(longjitude,latitude);
}

function showAddress_blue(longjitude,latitude)
{//byZS191222
   var gpsPoint = new BMap.Point(longjitude, latitude);
	map.setCenter(gpsPoint);
   if(!dragFlag)
   {
     //map.panTo(gpsPoint);
   }
    var marker_blue = new BMap.Marker(gpsPoint,{icon:PlaneIcon_blue});
    //marker.setPosition(gpsPoint);
	//map.centerAndZoom(gpsPoint,14);
    map.addOverlay(marker_blue);                              // 加载标注
    //marker.setAnimation(BMAP_ANIMATION_BOUNCE);        // 跳动的动画
}
//绿色
function showAddressAdjust_green(longjitude,latitude)
{//byZS191222
    //var resultPoint = GpsToBaiduPoint(new BMap.Point(longjitude,latitude));
    //showAddress_green(resultPoint.lng,resultPoint.lat);
	showAddress_green(longjitude,latitude);
}

function showAddress_green(longjitude,latitude)
{//byZS191222
   var gpsPoint = new BMap.Point(longjitude, latitude);
	map.setCenter(gpsPoint);
   if(!dragFlag)
   {
     //map.panTo(gpsPoint);
   }
    var marker_green = new BMap.Marker(gpsPoint,{icon:PlaneIcon_green});
    //marker.setPosition(gpsPoint);
	//map.centerAndZoom(gpsPoint,14);
    map.addOverlay(marker_green);                              // 加载标注
    //marker.setAnimation(BMAP_ANIMATION_BOUNCE);        // 跳动的动画
}
//黄色
function showAddressAdjust_yellow(longjitude,latitude)
{//byZS191222
    //var resultPoint = GpsToBaiduPoint(new BMap.Point(longjitude,latitude));
    //showAddress_yellow(resultPoint.lng,resultPoint.lat);
	showAddress_yellow(longjitude,latitude);
}

function showAddress_yellow(longjitude,latitude)
{//byZS191222
   var gpsPoint = new BMap.Point(longjitude, latitude);
	map.setCenter(gpsPoint);
   if(!dragFlag)
   {
     //map.panTo(gpsPoint);
   }
    var marker_yellow = new BMap.Marker(gpsPoint,{icon:PlaneIcon_yellow});
    //marker.setPosition(gpsPoint);
	//map.centerAndZoom(gpsPoint,14);
    map.addOverlay(marker_yellow);                              // 加载标注
    //marker.setAnimation(BMAP_ANIMATION_BOUNCE);        // 跳动的动画
}
//棕色
function showAddressAdjust_brown(longjitude,latitude)
{//byZS191222
    //var resultPoint = GpsToBaiduPoint(new BMap.Point(longjitude,latitude));
    //showAddress_brown(resultPoint.lng,resultPoint.lat);
	showAddress_brown(longjitude,latitude);
}

function showAddress_brown(longjitude,latitude)
{//byZS191222
   var gpsPoint = new BMap.Point(longjitude, latitude);
	map.setCenter(gpsPoint);
   if(!dragFlag)
   {
     //map.panTo(gpsPoint);
   }
    var marker_brown = new BMap.Marker(gpsPoint,{icon:PlaneIcon_brown});
    //marker.setPosition(gpsPoint);
	//map.centerAndZoom(gpsPoint,14);
    map.addOverlay(marker_brown);                              // 加载标注
    //marker.setAnimation(BMAP_ANIMATION_BOUNCE);        // 跳动的动画
}



function showAddressWaypoint(longjitude,latitude)
{
   var gpsPoint = new BMap.Point(longjitude, latitude);

   if(!dragFlag)
   {
     // map.panTo(gpsPoint);
   }
     //marker.setPosition(gpsPoint);
    var marker = new BMap.Marker(gpsPoint,{icon:myIcon});   // 创建标注
    map.addOverlay(marker);
}

//删除点

function deletePoint()
{
    var allOverlay = map.getOverlays();

    for(var i=0; i<allOverlay.length; i++)
    {
        //删除指定经度的点
        //if (allOverlay[i].getPosition().lng == 104.044444)
        {
            map.removeOverlay(allOverlay[i]);
        }
    }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function drowLine(x_lon,x_lat,y_lon,y_lat)
{
	var PointTrans1= GpsToBaiduPoint(new BMap.Point(x_lon,x_lat));
	var PointTrans2= GpsToBaiduPoint(new BMap.Point(y_lon,y_lat));
    var polyline22 = new BMap.Polyline  (                                         
                                            [new BMap.Point(PointTrans1.lng,PointTrans1.lat),new BMap.Point(PointTrans2.lng,PointTrans2.lat)],
                                            {
                                                strokeColor:"red",
                                                strokeWeight:3,
                                                strokeOpacity:1
                                            }
                                        );  //创建折线
    map.addOverlay(polyline22);
}

/********************展示轨迹函数***************************************************/
//蓝色轨迹
function drawPlaneTrack(x_lon,x_lat,y_lon,y_lat)
{   //byZS 191220,需要转换为百度坐标系，之前没有做转换
	//var PointTrans1= GpsToBaiduPoint(new BMap.Point(x_lon,x_lat));
	//var PointTrans2= GpsToBaiduPoint(new BMap.Point(y_lon,y_lat));
	var PointTrans1= new BMap.Point(x_lon,x_lat);
	var PointTrans2= new BMap.Point(y_lon,y_lat);
    var polyline22 = new BMap.Polyline  (                                         
                                            [new BMap.Point(PointTrans1.lng,PointTrans1.lat),new BMap.Point(PointTrans2.lng,PointTrans2.lat)],
                                            {
                                                strokeColor:"rgb(41, 117, 240)",
                                                strokeWeight:2,
                                                strokeOpacity:1
                                            }
                                        );  //创建折线
    
    map.addOverlay(polyline22);	
    map.panTo(new BMap.Point(PointTrans2.lng,PointTrans2.lat));    
    Plane_blue.setPosition(new BMap.Point(PointTrans2.lng,PointTrans2.lat));  
	
    map.addOverlay(Plane_blue); 
	
}

//红色轨迹
function drawPlaneTrack_error(x_lon,x_lat,y_lon,y_lat)
{   //byZS 191220,需要转换为百度坐标系，之前没有做转换
	//var PointTrans1= GpsToBaiduPoint(new BMap.Point(x_lon,x_lat));
	//var PointTrans2= GpsToBaiduPoint(new BMap.Point(y_lon,y_lat));
	var PointTrans1= new BMap.Point(x_lon,x_lat);
	var PointTrans2= new BMap.Point(y_lon,y_lat);
    var polyline22 = new BMap.Polyline  (                                         
                                            [new BMap.Point(PointTrans1.lng,PointTrans1.lat),new BMap.Point(PointTrans2.lng,PointTrans2.lat)],
                                            {
                                                strokeColor:"red",
                                                strokeWeight:2,
                                                strokeOpacity:1
                                            }
                                        );  //创建折线
    
    map.addOverlay(polyline22);	
    //map.panTo(new BMap.Point(PointTrans2.lng,PointTrans2.lat));    
    Plane.setPosition(new BMap.Point(PointTrans2.lng,PointTrans2.lat));  
	
    map.addOverlay(Plane); 
	
}
//绿色轨迹
function drawPlaneTrack_green(x_lon,x_lat,y_lon,y_lat)
{   //byZS 191220,需要转换为百度坐标系，之前没有做转换
	//var PointTrans1= GpsToBaiduPoint(new BMap.Point(x_lon,x_lat));
	//var PointTrans2= GpsToBaiduPoint(new BMap.Point(y_lon,y_lat));
	var PointTrans1= new BMap.Point(x_lon,x_lat);
	var PointTrans2= new BMap.Point(y_lon,y_lat);
    var polyline22 = new BMap.Polyline  (                                         
                                            [new BMap.Point(PointTrans1.lng,PointTrans1.lat),new BMap.Point(PointTrans2.lng,PointTrans2.lat)],
                                            {
                                                strokeColor:"rgb(157, 207, 135)",
                                                strokeWeight:2,
                                                strokeOpacity:1
                                            }
                                        );  //创建折线
    
    map.addOverlay(polyline22);	
    //map.panTo(new BMap.Point(PointTrans2.lng,PointTrans2.lat));    
    Plane_green.setPosition(new BMap.Point(PointTrans2.lng,PointTrans2.lat));  
	
    map.addOverlay(Plane_green); 
	
}
</script>